package com.rh.controller;

import com.rh.Enums;
import com.rh.dto.Result;
import com.rh.entity.WorkType;
import com.rh.excrptions.DoException;
import com.rh.mapper.WorkTypeMapper;
import com.rh.service.WorkTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@CrossOrigin
@ResponseBody
public class WorkTypeController {
    @Autowired
    private WorkTypeService workTypeService;

    /**
     * 查询全部类型
     * @return
     */
    @RequestMapping(value = "/getworkTypes",method = RequestMethod.GET)
    public Result getworkTypes() {
        try {
            Result result = new Result();
            List<WorkType> methodAll = workTypeService.getMethodAll();
            result.setData(methodAll);
            return result;
        }catch (Exception e){
            throw new DoException(Enums.GETLIST_ERROR);
        }
    }

}
